package com.example.mapper;

import com.example.entity.MI_Table;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 库存查询
 *
 * @author: liu
 * 2022-03-30-09:22
 **/
@Mapper
@Repository
public interface MedInfoQueryMapper {

    @Select("SELECT * FROM `t_medicine_info` WHERE m_name = #{m_name}")
    List<MI_Table> queryAllByName(@Param("m_name") String m_name);

    @Select("SELECT * FROM `t_medicine_info` where m_userid = #{m_userid} ORDER BY m_id")
    List<MI_Table> queryAllById(Integer m_userid);

    @Update("UPDATE t_medicine_info set m_inventory=#{m_inventory} where m_userid=#{m_userid} and m_id=#{m_id}")
    void updMedInfoWare(@Param("m_inventory")int m_inventory,@Param("m_userid")int m_userid,@Param("m_id")int m_id);

    @Select("SELECT m_kinds,COUNT(m_kinds) as kindNum FROM `t_medicine_info` WHERE m_userid=#{m_userid} GROUP BY m_kinds")
    List<MI_Table> queryKinds(@Param("m_userid") int userid);
}
